<template>
  <el-container class="container">
    <SideBar
      :isCollapse="isCollapse"
      @handleMenuItem="handleMenuItem"
    ></SideBar>
    <el-container>
      <el-header>
        <NavBar @handleCollapse="handleCollapse"> </NavBar
      ></el-header>
      <el-main>
        <!-- 面包屑 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>{{ menuName }} </el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 欢迎 -->
        <HomeWelcome
          v-if="this.$router.currentRoute.path === '/home'"
        ></HomeWelcome>
        <router-view class="rv"></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import SideBar from '../components/SideBar.vue'
import NavBar from '../components/NavBar.vue'
import HomeWelcome from '../components/HomeWelcome'
export default {
  name: 'HomeView',
  components: {
    SideBar,
    NavBar,
    HomeWelcome
  },
  data () {
    return {
      isCollapse: false,
      menuName: ' ',
      menuUrl: ''
    }
  },
  methods: {
    init () {
      const u = JSON.parse(sessionStorage.getItem('userInfo'))
      this.$store.commit('setUserInfo', u)
    },
    test () {
      this.$store.commit('changeCount', 1)
      this.$store.commit('changeCount', 1)
      this.$store.commit('changeCount', 2)
      this.$store.commit('changeCount', 3)
      console.log(this.$store.state.userInfo)
    },
    handleCollapse () {
      this.isCollapse = !this.isCollapse
    },
    handleMenuItem (item) {
      if (item) {
        console.log('handleMenuItemhandleMenuItemhandleMenuItem', item)
        this.menuName = item.name
        this.menuUrl = item.href
      }
    }
  },
  created () {
    this.init()
    // this.test()
  }
}
</script>
<style>
* {
  margin: 0;
  padding: 0;
}
/* 删除浏览器的滚动条 begin */

/* 设置浏览器滚动条的样式 */
::-webkit-scrollbar {
  width: 0px;
}
/* 滚动槽 */
::-webkit-scrollbar-track {
  -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.3);
  border-radius: 10px;
}
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.1);
  -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
  background: rgba(255, 0, 0, 0.4);
}

/* 删除浏览器的滚动条 end */

.container {
  width: 100%;
  height: 100%;
}
.el-header {
  padding: 0 !important;
}

.el-main {
  background-color: #f2f2f2;
  float: left;
  padding: 0px !important;
}
.el-breadcrumb {
  background-color: #fff;
  height: 40px;
  line-height: 40px;
  border-bottom: 1px solid #e2dddd;
  padding-left: 10px;
  box-sizing: border-box;
}
.rv {
  background-color: #fff;
  margin: 10px;
  padding: 10px;
  border-radius: 4px;
  overflow-y: auto;
}
</style>
